package com.geeyuu.android.service;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;

import com.geeyuu.android.utils.AndroidUtil;
import com.geeyuu.android.utils.CommonUtil;
import com.geeyuu.android.utils.LogUtil;

public class GeeReceiver extends BroadcastReceiver {
    
    @Override
    public void onReceive(Context context, Intent intent) {
        final String action = intent.getAction();
        LogUtil.v("GeeReceiver", "action:" + action);
        if(!CommonUtil.isEmpty(action)){
            if(action.equals(Intent.ACTION_BOOT_COMPLETED)){
                context.startService(new Intent(context, IMService.class));
            }else if(action.equals(ConnectivityManager.CONNECTIVITY_ACTION)){
                if (AndroidUtil.isNetworkAvailable(context)) {
                    LogUtil.v("GeeReceiver", "网络正常");
                }else{
                    LogUtil.v("GeeReceiver", "网络断了");
                }
            }
        }
    }

}
